<template>
	<view class="agreement-view">
		<video class="video" controls :src="content" v-if="type == 7"></video>
		<rich-text :nodes="content" v-else></rich-text>
	</view>
</template>

<script>
export default {
	data() {
		return {
			content: '',
			type: 1
		};
	},
	onLoad(options) {
		this.type = options.type;
		this.getAgreement();
	},
	onReady() {
		uni.setNavigationBarTitle({
			title: this.getTitle(this.type)
		});
	},
	methods: {
		async getAgreement() {
			var res = await this.$get('server/login/gethtml', {
				type: this.type
			});
			if (res.errcode != 0) {
				this.$toast(res.errmsg);
				return;
			}
			this.content = res.data.list.text;
		},
		getTitle(type) {
			if (type == 1) {
				return '用户协议';
			} else if (type == 2) {
				return '隐私政策';
			} else if (type == 3) {
				return '买家须知';
			} else if (type == 4) {
				return '活动规则';
			}
		}
	}
};
</script>

<style lang="scss" scoped>
page {
	background-color: #fff;
}
.agreement-view {
	padding: 30rpx;
}
.video {
	display: block;
	width: 100%;
}
</style>
